<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Predmet</title>
        <h:outputStylesheet library="css" name="styles.css"/> 
    </h:head>
    <h:body>
        <ui:include src="profMenuBar.xhtml"/>
        <h:form enctype="multipart/form-data">
            <p:panel header="Podesavanja" styleClass="headerPanel">
                <p:selectOneMenu id="nekidjavo" value="#{profBean.selectedP}" var="p" converter="courseConverter">
                    <f:selectItems value="#{profBean.PList}" var="predmet" itemLabel="#{predmet.naziv} - #{predmet.sifra}" itemValue="#{predmet}"/>
                    <p:ajax event="change"  update="predmeti" listener="#{profBean.initFileList()}"/>
                    <p:column>
                        #{p.naziv} - #{p.sifra}
                    </p:column>
                </p:selectOneMenu>
                <p:tabView id="predmeti">
                    <p:tab title="O predmetu">
                        <h:panelGrid columns="2">
                            <h:outputLabel value="Status predmeta:"/>
                            <p:selectOneMenu value="#{profBean.STipPredmeta}">
                                <f:selectItems value="#{profBean.tipPredmeta}"/>
                            </p:selectOneMenu>

                            <h:outputLabel value="Sifra predmeta:"/>
                            <p:inputText value="#{profBean.selectedP.sifra}"/>

                            <h:outputLabel value="ESPB:"/>
                            <p:inputText  value="#{profBean.selectedP.espb}"/>
                        </h:panelGrid>
                        <br/>
                        <h:outputLabel value="Uslov:"/>
                        <br/>
                        <br/>
                        <p:editor width="600" value="#{profBean.selectedP.propozicije}"/>
                        <br/>
                        <h:outputLabel value="Cilj predmeta:"/>
                        <br/>
                        <br/>
                        <p:editor width="600" />
                        <br/>
                        <p:commandButton value="Sacuvaj" action="#{profBean.updateCourse()}" ajax="false"/>
                    </p:tab>
                    <p:tab title="Predavanja">
                        <p:dataTable id="predavanjeTabela" value="#{profBean.predavanja}" var="v">
                            <p:column headerText="Naziv" sortBy="naziv">
                                <h:outputLabel value="#{v.naziv}"/>
                            </p:column>
                            <p:column headerText="Datum" sortBy="datum">
                                <h:outputLabel value="#{v.datum}"/>
                            </p:column>

                            <p:column headerText="Akcije">
                                <p:commandButton actionListener="#{profBean.deleteF(v)}" icon="ui-icon-trash" ajax="false"/>
                            </p:column>
                        </p:dataTable>
                        <br/><br/>
                        <p:fileUpload  mode="advanced" fileUploadListener="#{profBean.handleFileUploadPredavanja}" dragDropSupport="true" update="predavanjeTabela" />
                    </p:tab>
                    <p:tab title="Vezbe">
                        <p:dataTable id="vezbeTabela" value="#{profBean.vezbe}" var="v">
                            <p:column headerText="Naziv" sortBy="naziv">
                                <h:outputLabel value="#{v.naziv}"/>
                            </p:column>
                            <p:column headerText="Datum" sortBy="datum">
                                <h:outputLabel value="#{v.datum}"/>
                            </p:column>

                            <p:column headerText="Akcije">
                                <p:commandButton actionListener="#{profBean.deleteF(v)}" icon="ui-icon-trash" ajax="false"/>
                            </p:column>
                        </p:dataTable>
                        <br/><br/>
                        <p:fileUpload mode="advanced" fileUploadListener="#{profBean.handleFile}" dragDropSupport="true" update="vezbeTabela" />
                    </p:tab>
                    <p:tab title="Rokovi">
                        <p:dataTable id="rokoviTabela" value="#{profBean.rokovi}" var="v">
                            <p:column headerText="Naziv" sortBy="naziv">
                                <h:outputLabel value="#{v.naziv}"/>
                            </p:column>
                            <p:column headerText="Datum" sortBy="datum">
                                <h:outputLabel value="#{v.datum}"/>
                            </p:column>

                            <p:column headerText="Akcije">
                                <p:commandButton actionListener="#{profBean.deleteF(v)}" icon="ui-icon-trash" ajax="false"/>
                            </p:column>
                        </p:dataTable>
                        <br/><br/>
                        <p:fileUpload mode="advanced" fileUploadListener="#{profBean.handleFileUploadRokovi}" dragDropSupport="true" update="rokoviTabela" />
                    </p:tab>
                    <p:tab title="Laboratorijske vezbe">
                        <p:panel id="labVezba" header="Izaberi lab vezbu: ">
                            <h:panelGrid columns="2">
                                <p:outputLabel value="Laboratorijska vezba: "/>
                                <p:selectOneMenu value="#{profBean.selectedLab}" var="p" converter="labConverter">
                                    <f:selectItems value="#{profBean.toList(profBean.selectedP.labVezbes)}" var="lab" itemLabel="#{lab.naziv}" itemValue="#{lab}"/>
                                    <p:ajax event="change"  update="labVezba" listener="#{profBean.initLabFile()}"/>
                                    <p:column>
                                        #{p.naziv}
                                    </p:column>
                                </p:selectOneMenu>
                            </h:panelGrid>
                            <p:outputLabel value="Propozicije:"/> <br/><br/>
                            <p:editor value="#{profBean.selectedLab.propozicije}" width="600"/> <br/><br/>
                            <p:commandButton value="Sacuvaj" action="#{profBean.saveLab()}"/> <br/><br/>
                            <p:dataTable id="labVezbeTabela" value="#{profBean.labVezbeFajlovi}" var="v">
                                <p:column headerText="Naziv" sortBy="opis">
                                    <h:outputLabel value="#{v.naziv}"/>
                                </p:column>
                                <p:column headerText="Datum" sortBy="opis">
                                    <h:outputLabel value="#{v.datum}"/>
                                </p:column>

                                <p:column headerText="Akcije">
                                    <p:commandButton actionListener="#{profBean.deleteF(v)}" icon="ui-icon-trash" ajax="false"/>
                                </p:column>
                            </p:dataTable>
                            <br/><br/>
                            <p:fileUpload mode="advanced" fileUploadListener="#{profBean.handleFileUploadLab}" dragDropSupport="true" update="labVezba" />
                        </p:panel>
                    </p:tab>
                    <p:tab title="Domaci">
                        <p:panel id="domaci" header="Izaberi lab vezbu: ">
                            <h:panelGrid columns="2">
                                <p:outputLabel value="Domaci: "/>
                                <p:selectOneMenu value="#{profBean.selectedDomaci}" var="dm" converter="domaciConverter">
                                    <f:selectItems value="#{profBean.toList(profBean.selectedP.domacis)}" var="d" itemLabel="#{d.naziv}" itemValue="#{d}"/>
                                    <p:ajax event="change"  update="domaci" listener="#{profBean.initDomaciFile()}"/>
                                    <p:column>
                                        #{dm.naziv}
                                    </p:column>
                                </p:selectOneMenu>
                            </h:panelGrid>
                            <p:outputLabel value="Opis:"/> <br/><br/>
                            <p:editor value="#{profBean.selectedDomaci.opis}" width="600"/> <br/><br/>
                            <p:commandButton value="Sacuvaj" action="#{profBean.saveDomaci()}"/> <br/><br/>
                            <p:dataTable  value="#{profBean.domaciFajlovi}" var="v">
                                <p:column headerText="Naziv" sortBy="opis">
                                    <h:outputLabel value="#{v.naziv}"/>
                                </p:column>
                                <p:column headerText="Datum" sortBy="opis">
                                    <h:outputLabel value="#{v.datum}"/>
                                </p:column>

                                <p:column headerText="Akcije">
                                    <p:commandButton actionListener="#{profBean.deleteF(v)}" icon="ui-icon-trash" ajax="false"/>
                                </p:column>
                            </p:dataTable>
                            <br/><br/>
                            <p:fileUpload mode="advanced" fileUploadListener="#{profBean.handleFileUploadDomaci}" dragDropSupport="true" update="domaci" />
                        </p:panel>
                    </p:tab>
                </p:tabView>
            </p:panel>
        </h:form>
    </h:body>
</html>

